package com.fruit.message;

import com.fruit.model.OrderDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.annotation.StreamListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * @Description:
 * @Author: LJ
 * @Date: 2018/11/2 16:32
 * @version:
 */
@Component
@EnableBinding(StreamClient.class)
@Slf4j
public class StreamReceiver {


    /**
     * 接收orderDTO对象 消息
     * @param orderDTO
     */
    //接收1消息
    @StreamListener(value = StreamClient.INPUT)
    //返回发送给2消息
    @SendTo(StreamClient.INPUT2)
    public String process(OrderDTO orderDTO) {
        log.info("StreamReceiver: {}", orderDTO);
        return "received.";
    }
    //接收2消息
    @StreamListener(value = StreamClient.INPUT2)
    public void process2(String message) {
        log.info("StreamReceiver2: {}", message);
    }
}
